package com.xyh.test;

import com.xyh.po.Employee;
import com.xyh.po.Student;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.Properties;

/**
 * @Author:kyle
 * @Date:2020/12/10 - 11:21
 * @Project:spring_demo1
 * @Package:com.xyh.test
 * @Version:1.0
 */
public class test1 {
    final Logger log = LoggerFactory.getLogger(getClass());

    @Test
    public void test(){
        Student student = new Student(1,"熊大",188.5);
        System.out.println(student);
    }

    @Test
    public void test2(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        Student student = context.getBean("student", Student.class);
        System.out.println("student = " + student);
    }

    @Test
    public void test3(){

        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        Student student = context.getBean( Student.class,"student");
        log.info("{}",student);
    }

    @Test
    public void test4(){
        // 加载配置文件
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        // 通过配置文件，创建对象
        Employee employee = context.getBean("employee",Employee.class);
        log.info("{}",employee);

    }
}
